package com.mgface.jersey.core;

import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.message.GZipEncoder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.filter.EncodingFilter;
import org.glassfish.jersey.server.spring.scope.RequestContextFilter;

import com.mgface.jersey.exception.AppExecptionMapper;
import com.mgface.jersey.exception.NotFoundExceptionMapper;
import com.mgface.jersey.filters.CORSResponseFilter;
import com.mgface.jersey.filters.LoggingResponseFilter;
import com.mgface.jersey.resources.FirstResource;

public class MgfaceJAXRSApplication extends ResourceConfig {
	
	public MgfaceJAXRSApplication() {
		 // register application resources
		  register(FirstResource.class);

		  // register filters
		  register(RequestContextFilter.class);
		  register(CORSResponseFilter.class);
		  register(LoggingResponseFilter.class);

		  //register exception mappers
//		  register(GenericExceptionMapper.class);
		  register(AppExecptionMapper.class);
		  register(NotFoundExceptionMapper.class);
		  
		  //注册过滤器
		  //register(GZIPWriterInterceptor.class);

		  // register features
		  register(JacksonFeature.class);
		  //register(MultiPartFeature.class);
		  //register(EntityFilteringFeature.class); 
		  EncodingFilter.enableFor(this, GZipEncoder.class); 

	}
}
